import axios from "axios"
import { getToken } from "./token"

const req = axios.create({
    baseURL:'http://123.56.77.97:8080',
    timeout:5000
})


req.interceptors.request.use((config)=> {

    const token = getToken()
    if(token){
        config.headers.token = `${token}`
    }
    // console.log(config.headers);
    return config
},(error)=> {
    return Promise.reject(error)
})



req.interceptors.response.use((response)=>{
    return response.data
},(error)=>{
    return Promise.reject(error)
})

export { req }